package controller.commands
{
	import alternativa.engine3d.core.Object3D;
	import alternativa.types.Point3D;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Text;
	import mx.core.Application;
	
	import view.MiniCube;
	import view.MiniCubeFace;
	import view.UIControls;

	public class ShowCubeIDCommand implements ICommand
	{
		private var _console:Text;
		private var _ui:UIControls;
		private var _container:Object3D;
		
		public function ShowCubeIDCommand()
		{
			_console = Application.application.console;
			_ui = Application.application.engine.ui;
			_container = Application.application.engine.container;
		}

		public function execute(event:CairngormEvent):void
		{
			var minicube:MiniCube = event.data.cube as MiniCube
			var rotations:Point3D = new Point3D();
			var coords:Point3D = new Point3D(minicube.coords.x, minicube.coords.y, minicube.coords.z);
			var face:MiniCubeFace = event.data.face;
			rotations = face.transformation.getRotations();
			
			//minicube.addUI("front");
			//sminicube.transformation.deltaTransformVector(coords, _ui.coords);
			coords.transform(_container.transformation);
			_ui.coords = coords
			_ui.rotationX = rotations.x;
			_ui.rotationY = rotations.y;
			_ui.rotationZ = rotations.z;
			_console.text = rotations.toString();
		}
		
	}
}